<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>不良反应系统</title>
    <link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="/element-theme/blue/index.css">
</head>

<body>
<div class="data-manage-table">
    <template>
        <!--搜索查询-->
        <el-form ref="form" :inline="true" style="padding:20px 20px 0 20px;">
            <el-form-item label="不良反应编号">
                <el-input placeholder="请输入不良反应编号" v-model="searchSampleToConfirm.adverseReactionsNo"></el-input>
            </el-form-item>
            <el-form-item label="患者姓名">
                <el-input placeholder="请输入患者姓名" v-model="searchSampleToConfirm.name"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="clickSearch()">搜索</el-button>
                <el-button type="info" @click="emptySearch">重置</el-button>
                <el-button type="" @click="dialogVisible1 = true">登记</el-button>
                <el-button type="primary" style="margin-right: 40px;" @click="batchDelete()">批量删除</el-button>
<!--                <el-button type="" @click="exportExcel()">导出</el-button>-->
<!--                <el-button type="">打印</el-button>-->
            </el-form-item>
        </el-form>

        <el-dialog title="添加记录" center :visible.sync="dialogVisible1" width="45%" @close="cancel">
            <!-- 内容的主体区域 -->
            <el-form ref="form" :model="addForm" :rules="addFormRules" label-width="100px">
                <el-form-item label="反应编号" prop="adverseReactionsNo">
                    <el-input v-model="addForm.adverseReactionsNo"></el-input>
                </el-form-item>
                <el-form-item label="患者姓名" prop="name">
                    <el-input v-model="addForm.name"></el-input>
                </el-form-item>
                <el-form-item label="身份证号" prop="patientIdcard">
                    <el-input v-model="addForm.patientIdcard" maxlength="18"  show-word-limit></el-input>
                </el-form-item>
                <el-form-item label="反应症状" prop="transfusionReaction">
                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="addForm.transfusionReaction"></el-input>
<!--                    <el-input v-model="addForm.transfusionReaction"></el-input>-->
                </el-form-item>
                <el-form-item label="既往输血信息" prop="transfusionHistory">
                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="addForm.transfusionHistory"></el-input>
                </el-form-item>
                <el-form-item label="处理方法" prop="reactionProcessingMethod">
                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="addForm.reactionProcessingMethod"></el-input>
<!--                    <el-input v-model="addForm.reactionProcessingMethod"></el-input>-->
                </el-form-item>
                <el-form-item label="原因分析" prop="causeAnalysis">
                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="addForm.causeAnalysis"></el-input>
<!--                    <el-input v-model="addForm.causeAnalysis"></el-input>-->
                </el-form-item>
                <el-form-item label="发生时间" prop="reactionTime">
                    <el-date-picker v-model="addForm.reactionTime" type="datetime" size="small" format="yyyy-MM-dd HH:mm:ss"
                                    placeholder="发生时间" >
                    </el-date-picker>
                </el-form-item>
            </el-form>
            <!-- 底部区域 -->
            <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel()">取 消</el-button>
                    <el-button type="primary" @click="addAdverseReaction()">确 定</el-button>
                </span>
        </el-dialog>

        <el-dialog title="修改记录" center :visible.sync="dialogVisible2" width="45%" @close="cancelRevise">
            <!-- 内容的主体区域 -->
            <el-form ref="form" :model="reviseForm" :rules="reviseFormRules" label-width="100px">
<!--                <el-form-item label="患者编号" prop="Id">-->
<!--                    <el-input v-model="reviseForm.serialNumber"></el-input>-->
<!--                </el-form-item>-->
                <el-form-item label="反应编号" prop="adverseReactionsNo">
                    <el-input v-model="reviseForm.adverseReactionsNo"></el-input>
                </el-form-item>
                <el-form-item label="患者姓名" prop="name">
                    <el-input v-model="reviseForm.name"></el-input>
                </el-form-item>
                <el-form-item label="反应症状" prop="transfusionReaction">
                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="reviseForm.transfusionReaction"></el-input>
<!--                    <el-input v-model="reviseForm.transfusionReaction"></el-input>-->
                </el-form-item>
                <el-form-item label="处理方法" prop="reactionProcessingMethod">
                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="reviseForm.reactionProcessingMethod"></el-input>
<!--                    <el-input v-model="reviseForm.reactionProcessingMethod"></el-input>-->
                </el-form-item>
                <el-form-item label="原因分析" prop="causeAnalysis">
                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="reviseForm.causeAnalysis"></el-input>
<!--                    <el-input v-model="reviseForm.causeAnalysis"></el-input>-->
                </el-form-item>
                <el-form-item label="既往输血信息" prop="transfusionHistory">
                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="reviseForm.transfusionHistory"></el-input>
                </el-form-item>
                <el-form-item label="发生时间" prop="reactionTime">
                    <el-date-picker v-model="reviseForm.reactionTime" type="datetime" size="small" format="yyyy-MM-dd HH:mm:ss "
                                     placeholder="发生时间" >
                    </el-date-picker>
                </el-form-item>
            </el-form>
            <!-- 底部区域 -->
            <span slot="footer" class="dialog-footer">
                    <el-button @click="cancelRevise()">取 消</el-button>
                    <el-button type="primary" @click="reviseAdverseReaction()">确 定</el-button>
                </span>
        </el-dialog>

        <el-dialog title="删除记录" center :visible.sync="dialogVisible3" width="45%" @close="cancel">
            <!-- 内容的主体区域 -->
<!--            <el-form ref="form" :model="deleteForm" :rules="addFormRules" label-width="100px">-->
<!--                <el-form-item label="反应编号" prop="adverseReactionsNo">-->
<!--                    <el-input v-model="deleteForm.adverseReactionsNo"></el-input>-->
<!--                </el-form-item>-->
<!--                <el-form-item label="患者姓名" prop="name">-->
<!--                    <el-input v-model="deleteForm.name"></el-input>-->
<!--                </el-form-item>-->
<!--                <el-form-item label="反应症状" prop="transfusionReaction">-->
<!--                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="deleteForm.transfusionReaction"></el-input>-->
<!--&lt;!&ndash;                    <el-input v-model="deleteForm.transfusionReaction"></el-input>&ndash;&gt;-->
<!--                </el-form-item>-->
<!--&lt;!&ndash;                <el-form-item label="既往输血信息" prop="transfusionHistory">&ndash;&gt;-->
<!--&lt;!&ndash;                    <el-input v-model="deleteForm.transfusionHistory"></el-input>&ndash;&gt;-->
<!--&lt;!&ndash;                </el-form-item>&ndash;&gt;-->
<!--                <el-form-item label="处理方法" prop="reactionProcessingMethod">-->
<!--                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="deleteForm.reactionProcessingMethod"></el-input>-->
<!--&lt;!&ndash;                    <el-input v-model="deleteForm.reactionProcessingMethod"></el-input>&ndash;&gt;-->
<!--                </el-form-item>-->
<!--                <el-form-item label="原因分析" prop="causeAnalysis">-->
<!--                    <el-input type="textarea" :rows="2" placeholder="请输入内容" v-model="deleteForm.causeAnalysis"></el-input>-->
<!--&lt;!&ndash;                    <el-input v-model="deleteForm.causeAnalysis"></el-input>&ndash;&gt;-->
<!--                </el-form-item>-->
<!--                <el-form-item label="发生时间" prop="reactionTime">-->
<!--                    <el-date-picker v-model="deleteForm.reactionTime" type="datetime" size="small" format="yyyy-MM-dd HH:mm:ss"-->
<!--                                    placeholder="发生时间" >-->
<!--                    </el-date-picker>-->
<!--                </el-form-item>-->
<!--            </el-form>-->
            <!-- 底部区域 -->
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="deleteById()">确 定</el-button>
                <el-button @click="cancel()">取 消</el-button>

                </span>
        </el-dialog>
        <!-- 不良反应展示 -->
        <el-table :data="sampleInformation" style="width: 100%" border
                  ref="multipleTable"
                  type="selection"
                  :header-cell-style="{'text-align': 'center','background': '#eef1f6'}" highlight-current-row
                  @current-change="" id="out-table">
            <el-table-column type="selection" width="55" align="center"></el-table-column>

            <el-table-column prop="adverseReactionsNo" label="不良反应编号" width="100" align="center">
            </el-table-column>

            <el-table-column prop="name" label="患者姓名" width="180" align="center">
            </el-table-column>

            <el-table-column prop="patientIdcard" label="患者身份证号" width="180" align="center">
            </el-table-column>

            <el-table-column prop="reactionTime" label="反应发生时间" width="180" align="center">
                <template slot-scope="scope">
                    <i class="el-icon-time"></i>
                    <span style="margin-left: 10px">{{scope.row.reactionTime}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="transfusionReaction" label="不良反应症状" width="200" align="center">
            </el-table-column>

            <el-table-column prop="reactionProcessingMethod" label="反应处理方法" width="200" align="center">
            </el-table-column>

            <el-table-column prop="causeAnalysis" label="原因分析" width="200" align="center">
            </el-table-column>

            <el-table-column prop="transfusionHistory" label="既往输血信息" width="180" align="center">
            </el-table-column>

            <el-table-column fixed="right" label="操作" width="160" align="right">
                <template slot-scope="scope">
                    <el-button size="mini" type="danger" @click="handleEdit(scope.$index, scope.row)">修改</el-button>
                    </el-button>
                    <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除
                    </el-button>
                </template>
            </el-table-column>
        </el-table>

        <el-pagination :page-size="pageSize" :total="total" :current-page.sync="current" layout="prev, pager, next, jumper"
                       class="pagination"  @current-change="handleCurrentChange" style="text-align: center; margin-top: 20px;" />
    </template>
</div>

<script src="/plugins/vue-2.5.17/vue.js"></script>
<script src="/plugins/element-2.4.5/index.js"></script>
<script src="/icons/iconfont.js"></script>
<script src="/js/axios.min.js"></script>

<script>Vue.prototype.$ELEMENT = { size: 'medium' };</script>
<script language="JavaScript" type="text/javascript">
    //Date原型上添加格式转换方法
    Date.prototype.format = function(fmt) {
        const o = {
            "M+": this.getMonth() + 1,                 //月份
            "d+": this.getDate(),                    //日
            "h+": this.getHours(),                   //小时
            "m+": this.getMinutes(),                 //分
            "s+": this.getSeconds(),                 //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds()             //毫秒
        };
        if(/(y+)/.test(fmt)) {
            fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
        }
        for(const k in o) {
            if(new RegExp("("+ k +")").test(fmt)){
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
            }
        }
        return fmt;
    }
</script>
<script>Vue.prototype.$ELEMENT = { size: 'medium' };</script>
<script>
    (function () {
        var vm = window.vm = new Vue({
            el: '.data-manage-table',
            data() {
                //身份证校验
                const checkIdNum = (rule, value, callback) => {
                    if (!value) {
                        return callback(new Error('身份证不能为空'))
                    }
                    if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value)) {
                        callback(new Error('请输入正确的二代身份证号码'))
                    } else {
                        callback()
                    }
                }

                //纯中文校验
                const validateContacts = (rule, value, callback) => {
                    if (!value) {
                        return callback(new Error('请输入中文'))
                    }
                    if (!/^[\u0391-\uFFE5A-Za-z]+$/.test(value)) {
                        callback(new Error('不可输入特殊字符'))
                    } else {
                        callback()
                    }
                }
                //纯数字校验
                const validateNumber = (rule, value, callback) => {
                    let numberReg = /^\d+$|^\d+[.]?\d+$/
                    if (value !== '') {
                        if (!numberReg.test(value)) {
                            callback(new Error('请输入数字'))
                        } else {
                            callback()
                        }
                    } else {
                        callback(new Error('请输入值'))
                    }
                }

                return {
                    total: 0,   //总记录数
                    current: 1,     //当前页
                    pageSize: 10,      //每页记录数
                    pages: 0,       //总页数
                    signVisible: false,  //样本弹出框
                    dialogVisible1: false,  //弹出框显示
                    dialogVisible2:false,
                    dialogVisible3:false,
                    reviseForm: {},
                    // searchMode: false,  //false为没有查询条件，true为有查询条件
                    currentChanged: false,  //查询模式是否变化

                    //输入查询条件时保存
                    searchSampleToConfirm: {
                        adverseReactionsNo: '',  //不良反应编号
                        name: '',  //患者姓名
                    },

                    //搜索样本信息：点击搜索按钮时带入
                    searchSampleInformation: {
                        adverseReactionsNo: '',  //不良反应编号
                        name: '',  //患者姓名
                        dateVal: '',
                    },

                    //查询到的样本信息
                    sampleInformation: [],

                    //新增样本信息
                    addForm: {
                        id:'',
                        adverseReactionsNo: '',
                        patientIdcard:'',
                        name: '',
                        fever:'',
                        stomachCold:'',
                        chill:'',
                        vomiting:'',
                        headDistension:'',
                        dizzy:'',
                        headache:'',
                        sweating:'',
                        pale:'',
                        flushedComplexion:'',
                        ecchymosisOfSkin:'',
                        urticaria:'',
                        shortnessOfBreath:'',
                        asthma:'',
                        dryCough:'',
                        numbnessOfLimbs:'',
                        jaundice:'',
                        hemoglobinuria:'',
                        oliguria:'',
                        urosis:'',
                        hemolysis:'',
                        reactionTime:'',
                        transfusionReaction:'',
                        reactionProcessingMethod:'',
                        causeAnalysis:'',
                        reactionTime: '',
                        transfusionReaction: '',
                        reactionProcessingMethod: '',
                        causeAnalysis: '',
                        transfusionHistory: '',
                    },

                    reviseForm:{
                        id:'',
                        adverseReactionsNo: '',
                        patientIdcard:'',
                        name: '',
                        fever:'',
                        stomachCold:'',
                        chill:'',
                        vomiting:'',
                        headDistension:'',
                        dizzy:'',
                        headache:'',
                        sweating:'',
                        pale:'',
                        flushedComplexion:'',
                        ecchymosisOfSkin:'',
                        urticaria:'',
                        shortnessOfBreath:'',
                        asthma:'',
                        dryCough:'',
                        numbnessOfLimbs:'',
                        jaundice:'',
                        hemoglobinuria:'',
                        oliguria:'',
                        urosis:'',
                        hemolysis:'',
                        reactionTime:'',
                        transfusionReaction:'',
                        reactionProcessingMethod:'',
                        causeAnalysis:'',
                        reactionTime: '',
                        transfusionReaction: '',
                        reactionProcessingMethod: '',
                        causeAnalysis: '',
                        transfusionHistory: '',
                    },

                    deleteForm:{
                        id:'',
                        adverseReactionsNo: '',
                        patientIdcard:'',
                        name: '',
                        fever:'',
                        stomachCold:'',
                        chill:'',
                        vomiting:'',
                        headDistension:'',
                        dizzy:'',
                        headache:'',
                        sweating:'',
                        pale:'',
                        flushedComplexion:'',
                        ecchymosisOfSkin:'',
                        urticaria:'',
                        shortnessOfBreath:'',
                        asthma:'',
                        dryCough:'',
                        numbnessOfLimbs:'',
                        jaundice:'',
                        hemoglobinuria:'',
                        oliguria:'',
                        urosis:'',
                        hemolysis:'',
                        reactionTime:'',
                        transfusionReaction:'',
                        reactionProcessingMethod:'',
                        causeAnalysis:'',
                        reactionTime: '',
                        transfusionReaction: '',
                        reactionProcessingMethod: '',
                        causeAnalysis: '',
                        transfusionHistory: '',
                    },

                    //修改样本表单验证
                    reviseFormRules: {
                        // id:[
                        //     { required: true, message: '请输入患者编号', trigger: 'blur' },
                        // ],
                        adverseReactionsNo: [
                            { required: true, message: '请输入不良反应编号', trigger: 'change' },
                        ],
                        patientIdcard: [
                            { required: true, message: '请输入患者身份证号', trigger: 'blur' },
                            { validator: checkIdNum, trigger: 'blur'},
                        ],
                        name: [
                            { required: true, message: '请输入患者姓名', trigger: 'blur' },
                            {
                                validator:validateContacts,
                                trigger: "blur"
                            },
                        ],
                        transfusionReaction: [
                            { required: true, message: '请输入不良反应症状', trigger: 'blur' },
                        ],
                        reactionProcessingMethod: [
                            { required: true, message: '请输入反应处理方法', trigger: 'blur' },
                        ],
                        causeAnalysis: [
                            { required: true, message: '请输入原因分析', trigger: 'blur' },
                        ],
                        transfusionHistory: [
                            { required: true, message: '请输入输血信息', trigger: 'blur' },
                        ],
                    },

                    //新增样本表单验证
                    addFormRules: {
                        adverseReactionsNo: [
                            { required: true, message: '请输入不良反应编号', trigger: 'change' },
                        ],
                        name: [
                            { required: true, message: '请输入患者姓名', trigger: 'blur' },
                            {
                                validator:validateContacts,
                                trigger: "blur"
                            },
                        ],
                        patientIdcard: [
                            { required: true, message: '请输入患者身份证号', trigger: 'blur' },
                            { validator: checkIdNum, trigger: 'blur'},
                        ],
                        transfusionReaction: [
                            { required: true, message: '请输入不良反应症状', trigger: 'blur' },
                        ],
                        reactionProcessingMethod: [
                            { required: true, message: '请输入反应处理方法', trigger: 'blur' },
                        ],
                        causeAnalysis: [
                            { required: true, message: '请输入原因分析', trigger: 'blur' },
                        ],
                        transfusionHistory: [
                            { required: true, message: '请输入输血信息', trigger: 'blur' },
                        ],
                    }
                }
            },

            computed: {
                //false为没有查询条件，true为有查询条件
                searchMode() {
                    if (this.searchSampleInformation.adverseReactionsNo == "" && this.searchSampleInformation.name == "" && this.searchSampleInformation.dateVal == "")
                        return false
                    else
                        return true
                }
            },

            watch: {
                //监听搜索，条件搜索到无条件搜索，current变为1，反之依然
                'searchMode': function (newVal, oldVal) {
                    this.currentChanged = true
                },
                //搜素条件改变时，cunrrent也要变为1
                'searchSampleInformation': {
                    deep: true,
                    handler(newVal, oldVal) {
                        this.currentChanged = true
                    }
                }
            },

            methods: {
                //分页查询，显示在table中
                fetchPageData(current, limit) {
                    axios({
                        method: "get",
                        url: "/blood_adverse/normal/listByPage",
                        params: {
                            currentPage: this.current,
                            pageSize: this.pageSize
                        }
                    }).then(res => {
                        if (res.status == '200') {
                            this.sampleInformation = res.data.data;  //更新数据
                            console.log(res.data.data)
                            this.total = res.data.total;
                            this.pages = res.data.pages;
                        } else {
                            this.total = res.data.total;
                            this.pages = res.data.pages;
                            this.$notify({
                                tile: '警告',
                                message: '获取分页服务内部错误',
                                type: 'warning'
                            })
                        }
                    }).catch(err => {
                        this.$notify.error({
                            title: '错误',
                            message: '获取分页数据失败',
                        })
                    })
                },

                handleEdit(index, row){
                    this.dialogVisible2 = true
                    console.log(row)
                    this.reviseForm = row
                },

                handleDelete(index,row){
                    this.dialogVisible3 = true
                    console.log(row)
                    this.deleteForm = row
                },

                //点击页码
                handleCurrentChange: function (val) {
                    this.current = val;
                    if (!this.searchMode)
                        this.fetchPageData(this.current, this.pageSize)
                    else
                        this.searchSample()
                },

                //身份证号正则验证


                //点击搜索按钮
                clickSearch(){
                    this.current = 1
                    this.searchSampleInformation = JSON.parse(JSON.stringify(this.searchSampleToConfirm))
                    this.searchSample()
                },

                // 批量删除
                batchDelete() {
                    if(JSON.parse(JSON.stringify(this.$refs.multipleTable.selection)).length==0){
                        this.$notify({
                            title: '温馨提示：',
                            message: '您未选中数据，请重新操作！！！',
                            type: 'warning'
                        });
                        return;
                    }
                    let checkArr = JSON.parse(JSON.stringify(this.$refs.multipleTable.selection));  // 存储了勾选到的数据
                    var ids=new Array()
                    for(var i=0;i<checkArr.length;i++){
                        ids[i]=checkArr[i].id;
                    }
                    // let data={ids:ids}
                    //批量删除
                    this.$confirm('确定删除这些数据吗, 是否继续?', '批量删除', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        axios({
                            url: '/blood_adverse/normal/batchDelete',
                            method: 'put',
                            dataType: 'json',
                            data:ids
                        }).then(res => {
                            if (res.data.code == '200') {
                                this.$notify({
                                    tile: '温馨提示',
                                    message: '批量删除成功！！！',
                                    type: 'success'
                                })
                                this.fetchPageData(this.current, this.limit)
                            } else {
                                this.$notify({
                                    tile: '警告',
                                    message: '删除出错',
                                    type: 'warning'
                                })
                            }
                        }).catch(err => {
                            this.$notify.error({
                                title: '错误',
                                message: '删除失败',
                            })
                        });
                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消删除'
                        });
                    });
                },

                //根据查询条件查询血液样本
                searchSample() {
                    console.log(this.searchSampleInformation)
                    //不良反应编号
                    let adverseReactionsNo = this.searchSampleToConfirm.adverseReactionsNo
                    //患者姓名
                    let name = this.searchSampleInformation.name


                    // if (this.currentChanged) {
                    //     this.current = 1
                    //     this.currentChanged = false
                    // }

                    //依据是否有查询条件，进行不一样的查询
                    if (!this.searchMode) {
                        this.fetchPageData(this.current, this.pageSize)
                    } else {
                        axios({
                            url: '/blood_adverse/normal/searchSample',
                            method: 'get',
                            params: {
                                adverseReactionsNo: adverseReactionsNo,
                                name: name,
                                currentPage: this.current,
                                pageSize: this.pageSize,
                            },
                        }).then(res => {
                            console.log(res)
                            if (res.status == '200') {
                                this.sampleInformation = res.data.data;
                                this.total = res.data.total;
                                this.pages = res.data.pages;
                            } else {
                                this.$notify({
                                    tile: '警告',
                                    message: '搜索出错',
                                    type: 'warning'
                                })
                            }
                        }).catch(err => {
                            this.$notify.error({
                                title: '错误',
                                message: '搜索失败',
                            })
                        })
                    }
                },

                //清空搜索条件
                emptySearch() {
                    for (const key in this.searchSampleInformation)
                        this.searchSampleInformation[key] = ""
                    for (const key in this.searchSampleToConfirm)
                        this.searchSampleToConfirm[key] = ""
                },

                //添加样本信息
                addAdverseReaction() {
                    let newSample = this.addForm
                    // newSample.adverseReactionsNo = GenerateNumberBySnowFlake.genNumberByflag
                    newSample.reactionTime.format("yyyy-MM-dd HH:mm:ss")
                    if(this.verifyAddAdverseReaction(newSample)){
                        axios({
                            url: '/blood_adverse/normal/addAdverseReaction',
                            method: 'post',
                            data: {
                                adverseReaction: newSample
                            }
                        }).then(res => {
                            if (res.data.code == '200') {
                                console.log('插入成功')
                                this.cancel()
                                this.$notify({
                                    tile: '成功',
                                    message: '登记成功',
                                    type: 'success'
                                })
                                this.fetchPageData(this.current, this.limit)
                            } else {
                                this.$notify({
                                    tile: '警告',
                                    message: '更新出错',
                                    type: 'warning'
                                })
                            }
                        }).catch(err => {
                            this.$notify.error({
                                title: '错误',
                                message: '更新失败',
                            })
                        })
                    }
                    else {
                        alert('样本信息错误')
                    }
                    this.dialogVisible1 = false
                },

                //修改样本信息
                reviseAdverseReaction() {
                    let newSample = this.reviseForm
                    if(this.verifyAddAdverseReaction(newSample)){
                        axios({
                            url: '/blood_adverse/normal/reviseAdverseReaction',
                            method: 'put',
                            data: {
                                adverseReaction: newSample
                            }
                        }).then(res => {
                            if (res.data.code == '200') {
                                console.log('插入成功')
                                this.cancel()
                                this.$notify({
                                    tile: '成功',
                                    message: '登记成功',
                                    type: 'success'
                                })
                                this.fetchPageData(this.current, this.limit)
                            } else {
                                this.$notify({
                                    tile: '警告',
                                    message: '更新出错',
                                    type: 'warning'
                                })
                            }
                        }).catch(err => {
                            this.$notify.error({
                                title: '错误',
                                message: '更新失败',
                            })
                        })
                    }
                    else {
                        alert('样本信息错误')
                    }
                    this.dialogVisible2 = false
                },

                //新增样本信息检查
                verifyAddAdverseReaction(newSample){
                    if (newSample.adverseReactionsNo == '' || newSample.adverseReactionsNo == null)
                        return false
                    if (newSample.name == '' || newSample.name == null)
                        return false
                    // if (newSample.bloodNumber.length > 10 || newSample.operatorNumber.length > 20){
                    //     console.log('bloodNumber太长')
                    //     return false
                    // }
                    return true
                    this.dialogVisible1 = false
                },

                //录入样本：点击确定按钮
                confirmReceive(){
                    if (this.currentChanged) {
                        this.current = 1
                        this.currentChanged = false
                    }
                    axios({
                        url: '/blood_adverse/normal/receiveSample',
                        method: 'post',
                        data: this.receiveForm
                    }).then(res => {
                        if (res.data.code == '200') {
                            if(this.sampleInformation.length == 1)
                                this.current = 1
                            if(res.data.pages < this.current)
                                this.current = res.data.pages
                            this.handleCurrentChange(this.current)
                            this.signVisible = false
                            this.$notify({
                                tile: '成功',
                                message: '录入成功',
                                type: 'success'
                            })
                        } else {
                            this.$notify({
                                tile: '警告',
                                message: '录入失败',
                                type: 'warning'
                            })
                        }
                    }).catch(err => {
                        this.$notify.error({
                            title: '错误',
                            message: '录入失败',
                        })
                    })
                },

                //删除信息
                deleteById() {
                    let sample_select = this.deleteForm;
                    if (this.currentChanged) {
                        this.current = 1
                        this.currentChanged = false
                    }
                    axios({
                        url: '/blood_adverse/normal/deleteById',
                        method: 'delete',
                        data: sample_select
                    }).then(res => {
                        //需要再次进行查询，同时处理当前页无数据的情况
                        if (res.data.code == '200') {
                            console.log('current:'+this.current+' length:'+this.sampleInformation.length)
                            if(this.sampleInformation.length == 1)
                                this.current = 1
                            this.handleCurrentChange(this.current)
                            this.$notify({
                                title: '成功',
                                message: '删除成功',
                                type: 'success'
                            })
                        } else {
                            this.$notify({
                                tile: '警告',
                                message: '删除出错',
                                type: 'warning'
                            })
                        }
                    }).catch(err => {
                        this.$notify.error({
                            title: '错误',
                            message: '删除失败',
                        })
                    })
                    this.dialogVisible3 = false
                },

                //取消按钮
                cancel(){
                    this.addForm.adverseReactionsNo = ''
                    this.addForm.patientIdcard = ''
                    this.addForm.name = ''
                    this.addForm.fever = ''
                    this.addForm.stomachCold = ''
                    this.addForm.chill = ''
                    this.addForm.vomiting = ''
                    this.addForm.headDistension = ''
                    this.addForm.dizzy = ''
                    this.addForm.headache = ''
                    this.addForm.sweating = ''
                    this.addForm.pale = ''
                    this.addForm.flushedComplexion = ''
                    this.addForm.ecchymosisOfSkin = ''
                    this.addForm.urticaria = ''
                    this.addForm.shortnessOfBreath = ''
                    this.addForm.asthma = ''
                    this.addForm.dryCough = ''
                    this.addForm.numbnessOfLimbs = ''
                    this.addForm.jaundice = ''
                    this.addForm.hemoglobinuria = ''
                    this.addForm.oliguria = ''
                    this.addForm.urosis = ''
                    this.addForm.hemolysis = ''
                    this.addForm.reactionTime = ''
                    this.addForm.transfusionReaction = ''
                    this.addForm.reactionProcessingMethod = ''
                    this.addForm.causeAnalysis = ''
                    this.dialogVisible1 = false
                    this.dialogVisible3 = false
                },

                //取消按钮
                cancelRevise(){
                    this.dialogVisible2 = false
                },

                //导出excel
                exportExcel () {
                    //不良反应编号
                    let adverseReactionsNo = this.searchSampleInformation.adverseReactionsNo
                    //患者姓名
                    let name = this.searchSampleInformation.name
                    //发热
                    let fever = this.searchSampleInformation.fever
                    //胃寒
                    let stomachCold = this.searchSampleInformation.stomachCold
                    //寒战
                    let chill = this.searchSampleInformation.chill
                    //呕吐
                    let vomiting = this.searchSampleInformation.vomiting
                    //头胀
                    let headDistension = this.searchSampleInformation.headDistension
                    //头晕
                    let dizzy = this.searchSampleInformation.dizzy
                    //头痛
                    let headache = this.searchSampleInformation.headache
                    //出汗
                    let sweating = this.searchSampleInformation.sweating
                    //面色苍白
                    let pale = this.searchSampleInformation.pale
                    //面色潮红
                    let flushedComplexion = this.searchSampleInformation.flushedComplexion
                    //皮肤紫绀
                    let cyanosisOfSkin = this.searchSampleInformation.cyanosisOfSkin
                    //皮肤瘀点
                    let ecchymosisOfSkin = this.searchSampleInformation.ecchymosisOfSkin
                    //荨麻疹
                    let urticaria = this.searchSampleInformation.urticaria
                    //胸闷
                    let chestTightness = this.searchSampleInformation.chestTightness
                    //呼吸急促
                    let shortnessOfBreath = this.searchSampleInformation.shortnessOfBreath
                    //哮喘
                    let asthma = this.searchSampleInformation.asthma
                    //干咳
                    let dryCough = this.searchSampleInformation.dryCough
                    //四肢麻木
                    let numbnessOfLimbs = this.searchSampleInformation.numbnessOfLimbs
                    //黄疸
                    let jaundice = this.searchSampleInformation.jaundice
                    //血红蛋白尿
                    let hemoglobinuria = this.searchSampleInformation.hemoglobinuria
                    //尿少
                    let oliguria = this.searchSampleInformation.oliguria
                    //尿闭
                    let urosis = this.searchSampleInformation.urosis
                    //溶血
                    let hemolysis = this.searchSampleInformation.hemolysis
                    //不良反应发生时间
                    let reactionTime = this.searchSampleInformation.reactionTime
                    //不良反应症状
                    let transfusionReaction = this.searchSampleInformation.transfusionReaction
                    //反应处理方法
                    let reactionProcessingMethod = this.searchSampleInformation.reactionProcessingMethod
                    //原因分析
                    let causeAnalysis = this.searchSampleInformation.causeAnalysis
                    //创建a标签元素
                    const a = document.createElement('a')
                    a.href = 'http://localhost:8080/blood_adverse/downloadExcel' + '&adverseReactionsNo=' + adverseReactionsNo +
                        '&name=' + name  + '&fever' + fever + '&stomachCold' + stomachCold + '&chill' + chill +
                        '&vomiting' + vomiting + '&headDistension' + headDistension + '&dizzy' + dizzy +
                        '&headache' + headache + '&sweating' + sweating + '&pale' + pale + '&flushedComplexion' + flushedComplexion +
                        '&cyanosisOfSkin' + cyanosisOfSkin + '&ecchymosisOfSkin' + ecchymosisOfSkin + '&urticaria' + urticaria +
                        '&chestTightness'  + chestTightness + '&shortnessOfBreath' + shortnessOfBreath + '&asthma'  + asthma +
                        '&dryCough' + dryCough + '&numbnessOfLimbs' + numbnessOfLimbs + '&jaundice'  + jaundice +
                        '&hemoglobinuria' + hemoglobinuria + '&oliguria' + oliguria + '&urosis' + urosis + '&hemolysis' + hemolysis +
                        '&reactionTime' + reactionTime + '&transfusionReaction' + transfusionReaction + '&reactionProcessingMethod' +
                        reactionProcessingMethod + '&causeAnalysis' + causeAnalysis +
                        '&transfusionHistory' + transfusionHistory
                    console.log(a.href)
                    a.click()
                }

            },

            mounted() {
                this.fetchPageData(this.current, this.limit)
            }

        });
    })()
</script>

</body>

</html>